﻿@using KL.Store.Core
@{
    Layout = "~/Views/Shared/" + Parameters.Layout + ".cshtml";
    var cssClass = "col-xs-12 col-sm-12 col-md-3 col-lg-2 left first last";
    var pSort = 4;
    var pOrder = 2;
    if (Parameters.Theme == "DK")
    {
        cssClass = "col-xs-12 col-sm-12 col-md-4 col-lg-3 left first";
    }
    else if (Parameters.Theme == "EO")
    {
        cssClass = "col-xs-12 col-sm-12 col-md-4 col-lg-3 left first";
    }
    else if (Parameters.Theme == "WU")
    {
        cssClass = "col-xs-12 col-sm-12 col-md-3 col-lg-3 left";
    }
    else if (Parameters.Theme == "JB")
    {
        pSort = 3;
        pOrder = 2;
    }
}
<div class="@cssClass">
    @if (Parameters.ShowCategoryOnProductsPages)
    {
        Html.RenderAction("Categories", "Partials");
    }
    @if (Parameters.ShowBrandSelection)
    {
        Html.RenderAction("Brands", "Partials");
    }
    <form name="product-filter" method="get">
        @if (Parameters.ShowBrandFilter || ViewBag.IsManager || ViewBag.IsSeoManager)
        {
            Html.RenderAction("GetBrandsSelection", "Products", new { id = ViewContext.RouteData.Values["id"] });
        }
        <div class="product-filter">
            <div class="product-filter-inner">
                <h5 class="product-filter-title">Fiyat Aralığı  @if (!Parameters.ShowPriceRangeAsCheckbox)
                                                                {<text>(TL)</text>}</h5>
                <div class="product-filter-options">
                    <ul class="price-range-inputs" @{ if (Parameters.ShowPriceRangeAsCheckbox)
                                                      {<text>style="display:none;"</text>} }>
                        <li>
                            <input type="text" name="enAzUcret" id="enAzUcret" class="form-control" disabled="disabled" />
                        </li>
                        <li class="price-range-and">ve</li>
                        <li>
                            <input type="text" name="enFazlaucret" id="enFazlaucret" class="form-control" disabled="disabled" />
                        </li>
                    </ul>
                    @if (Parameters.ShowPriceRangeAsCheckbox)
                    {
                        <ul class="price-range-check">
                        </ul>
                    }
                    <div class="clearfix"></div>
                    @if (!Parameters.ShowPriceRangeAsCheckbox)
                    {
                        <div id="price-range"></div>
                    }
                </div>
                <div class="clearfix"></div>
            </div>
        </div>
        @{ if (Parameters.WebSiteTitle != "sTest Company")
           {
               Html.RenderAction("GetPropertySelection", "Products", new { id = ViewContext.RouteData.Values["id"] });
           }
        }
    </form>
</div>
<div id="content">
    @{
        Html.RenderAction("PackagesGet", "Products", new { id = ViewContext.RouteData.Values["id"], brand = ViewContext.RouteData.Values["brand"], sort = pSort, order = pOrder, itemCount = Parameters.MaxProductCountForPage, ColumnCount = ViewBag.ColumnCount, ListImageType = ViewBag.ListImageType, ShowcaseGroup = ViewBag.ShowcaseGroup });
    }
</div>
<script>
    var minPriceDefault = 0;
    if ((parseInt($('#minPriceDefault').val()) - 1) >= 0)
    {
        minPriceDefault = parseInt($('#minPriceDefault').val()) - 1;
    }
    var maxPriceDefault = parseInt($('#maxPriceDefault').val()) + 1;
</script>
@if (Parameters.ShowPriceRangeAsCheckbox)
{
    <script>
        //var aralikKatsayi = 2;
        //var aralikArtisi = 150;
        //var guncelBaslangic = minPriceDefault;
        //var guncelAralik = 0;
        //while (guncelAralik <= maxPriceDefault) {

        //}
        $(function ()
        {
            if (minPriceDefault < 50)
            {
                $('.price-range-check').append('<li><input class="product-range-input-check" type="checkbox" id="aralik050" data-min="0" data-max="50" /><label for="aralik050">0 TL - 50 TL</label></li>');
            }
            if (maxPriceDefault >= 50 && minPriceDefault <= 100)
            {
                $('.price-range-check').append('<li><input class="product-range-input-check" type="checkbox" id="aralik50100" data-min="50" data-max="100" /><label for="aralik50100">50 TL - 100 TL</label></li>');
            }
            if (maxPriceDefault >= 100 && minPriceDefault <= 250)
            {
                $('.price-range-check').append('<li><input class="product-range-input-check" type="checkbox" id="aralik100250" data-min="100" data-max="250" /><label for="aralik100250">100 TL - 250 TL</label></li>');
            }
            if (maxPriceDefault >= 250 && minPriceDefault <= 500)
            {
                $('.price-range-check').append('<li><input class="product-range-input-check" type="checkbox" id="aralik250500" data-min="250" data-max="500" /><label for="aralik250500">250 TL - 500 TL</label></li>');
            }
            if (maxPriceDefault >= 500 && minPriceDefault <= 750)
            {
                $('.price-range-check').append('<li><input class="product-range-input-check" type="checkbox" id="aralik500750" data-min="500" data-max="750" /><label for="aralik500750">500 TL - 750 TL</label></li>');
            }
            if (maxPriceDefault >= 750 && minPriceDefault <= 1000)
            {
                $('.price-range-check').append('<li><input class="product-range-input-check" type="checkbox" id="aralik7501000" data-min="750" data-max="1000" /><label for="aralik7501000">750 TL - 1000 TL</label></li>');
            }
            if (maxPriceDefault >= 1000 && minPriceDefault <= 1500)
            {
                $('.price-range-check').append('<li><input class="product-range-input-check" type="checkbox" id="aralik10001500" data-min="1000" data-max="1500" /><label for="aralik10001500">1000 TL - 1500 TL</label></li>');
            }
            if (maxPriceDefault >= 1500 && minPriceDefault <= 2500)
            {
                $('.price-range-check').append('<li><input class="product-range-input-check" type="checkbox" id="aralik15002500" data-min="1500" data-max="2500" /><label for="aralik15002500">1500 TL - 2500 TL</label></li>');
            }
            if (maxPriceDefault >= 2500 && minPriceDefault <= 5000)
            {
                $('.price-range-check').append('<li><input class="product-range-input-check" type="checkbox" id="aralik25005000" data-min="2500" data-max="5000" /><label for="aralik25005000">2500 TL - 5000 TL</label></li>');
            }
            if (maxPriceDefault >= 5000 && minPriceDefault <= 10000)
            {
                $('.price-range-check').append('<li><input class="product-range-input-check" type="checkbox" id="aralik500010000" data-min="5000" data-max="10000" /><label for="aralik500010000">5000 TL - 10000 TL</label></li>');
            }
            if (maxPriceDefault >= 10000)
            {
                $('.price-range-check').append('<li><input type="checkbox" id="aralik1000plus" data-min="10000" data-max="9999999999" /><label for="aralik1000plus">10000\'den Fazla</label></li>');
            }

            $(".product-range-input-check").change(function ()
            {
                var checkedInputId = $(this).attr("id");
                var checkedFound = false;
                $(".product-range-input-check").each(function ()
                {
                    if ($(this).attr("id") != checkedInputId)
                    {
                        $(this).attr("checked", false);
                    }
                    if ($(this).attr("checked"))
                    {
                        checkedFound = true;
                    }
                });
                if (checkedFound)
                {
                    $("#enAzUcret").val($(this).attr("data-min"));
                    $("#enFazlaucret").val($(this).attr("data-max"));
                }
                else
                {
                    $("#enAzUcret").val(0);
                    $("#enFazlaucret").val(99999999999);
                }
                SortMinMaxPrice();
            });

            $(".product-filter-options").customScrollbar();
            $(".product-filter-options .scroll-bar .thumb").html("<div class=\"thumb-image\"></div>");
        });


    </script>
}
else
{
    <script>
        $("#price-range").slider({
            range: true,
            min: minPriceDefault,
            max: maxPriceDefault,
            values: [minPriceDefault, maxPriceDefault],
            slide: function (event, ui)
            {
                $("#enAzUcret").val(ui.values[0]);
                $("#enFazlaucret").val(ui.values[1]);
            },
            change: function (event, ui)
            {
                SortMinMaxPrice();
            }
        });
        $("#enAzUcret").val($("#price-range").slider("values", 0));
        $("#enFazlaucret").val($("#price-range").slider("values", 1));
    </script>
}